home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / rpc / rpcHistogram.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  3.0 KB  |  83 lines

  1. /*
  2.  * rpcHistogram.h --
  3.  *
  4.  *    Definitions for the histograms of event durations.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/rpc/rpcHistogram.h,v 9.3 92/07/09 21:46:42 kupfer Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _RPCHISTOGRAM
  14. #define _RPCHISTOGRAM
  15.  
  16. #include <spriteTime.h>
  17. #ifdef KERNEL
  18. #include <sync.h>
  19. #else
  20. #include <kernel/sync.h>
  21. #endif /* KERNEL */
  22.  
  23. /*
  24.  * An empirical time distribution is kept in the following structure.
  25.  * This includes the average, plus an array of calls vs. microseconds
  26.  * with some granularity on the time for each bucket.  We explicitly 
  27.  * specify a kernel lock, so that we can copyout this struct to a user
  28.  * program and have the user program understand what it's getting.
  29.  */
  30. typedef struct Rpc_Histogram {
  31.     Sync_KernelLock lock;    /* Used to monitor access to histogram */
  32.     int numCalls;        /* The total number of calls */
  33.     Time aveTimePerCall;    /* The average interval duration */
  34.     Time totalTime;        /* The total time spent in the calls */
  35.     Time overheadTime;        /* Overhead cost per call */
  36.     int    usecPerBucket;        /* The granularity of the histogram */
  37.     int numHighValues;        /* Count of out-of-bounds values */
  38.     int bucketShift;        /* Used to map from time to bucket */
  39.     int numBuckets;        /* The number of slots in the histogram */
  40.     int *bucket;        /* The array of counters */
  41. } Rpc_Histogram;
  42.  
  43. /*
  44.  * This is the size of all the histograms kept by the system.
  45.  * Although they could vary in size, one size is used in order to
  46.  * simplify the interface to the user program that prints out
  47.  * the histograms.
  48.  */
  49. #define RPC_NUM_HIST_BUCKETS 50
  50. /*
  51.  * The service time is measured on both the client and the server.
  52.  * These flags enable/disable this measurement.  The macros are used
  53.  * to invoke the tracing procedures, subject to the flags.
  54.  */
  55. extern Boolean rpcServiceTiming;
  56. extern Boolean rpcCallTiming;
  57.  
  58. #define RPC_CALL_TIMING_START(command, timePtr) \
  59.     if (rpcCallTiming) { \
  60.     Rpc_HistStart(rpcCallTime[command], timePtr); \
  61.     }
  62. #define RPC_CALL_TIMING_END(command, timePtr) \
  63.     if (rpcCallTiming) { \
  64.     Rpc_HistEnd(rpcCallTime[command], timePtr); \
  65.     }
  66. #define RPC_SERVICE_TIMING_START(command, timePtr) \
  67.     if (rpcServiceTiming) { \
  68.     Rpc_HistStart(rpcServiceTime[command], timePtr); \
  69.     }
  70. #define RPC_SERVICE_TIMING_END(command, timePtr) \
  71.     if (rpcServiceTiming) { \
  72.     Rpc_HistEnd(rpcServiceTime[command], timePtr); \
  73.     }
  74.  
  75. extern Rpc_Histogram *Rpc_HistInit _ARGS_((int numBuckets, int usecPerBucket));
  76. extern void Rpc_HistReset _ARGS_((register Rpc_Histogram *histPtr));
  77. extern void Rpc_HistStart _ARGS_((register Rpc_Histogram *histPtr, register Time *timePtr));
  78.  extern void Rpc_HistEnd _ARGS_((register Rpc_Histogram *histPtr, register Time * timePtr));
  79. extern ReturnStatus Rpc_HistDump _ARGS_((register Rpc_Histogram *histPtr, register Address buffer));
  80. extern void Rpc_HistPrint _ARGS_((register Rpc_Histogram *histPtr));
  81.  
  82. #endif /* _RPCHISTOGRAM */
  83.